-
Notifications
You must be signed in to change notification settings - Fork 800
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Social | Add wpcom/v3/publicize/connections
endpoint
#40540
Conversation
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖 The e2e test report can be found here. Please note that it can take a few minutes after the e2e tests checks are complete for the report to be available. Follow this PR Review Process:
Still unsure? Reach out in #jetpack-developers for guidance! |
/** | ||
* Publicize Connection Fields class. | ||
*/ | ||
class Connection_Fields { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The methods in this class are copied from Publicize_Base class which we can later on clean up to these methods as fallback after deprecating them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we might be doing too much in one go here. We should definitely be doing some refactoring of the Publicize_Base class, but I'm not sure if we want to tackle that at the same time.
It would be good to do the smallest change that fixes our problem.
'title' => 'jetpack-publicize-connection', | ||
'type' => 'object', | ||
'properties' => array( | ||
'connection_id' => array( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at this, the endpoint exists because we need to rename a couple of fields and add some more. Would it be possible to extend the current connection test results endpoint, and create a version 2.1 from there?
We're copying quite a bit of code and creating a third set of endpoints, which we should probably avoid if we can.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be possible to extend the current connection test results endpoint, and create a version 2.1 from there?
I initially tried to update that endpoint to enhance it but it resulted in complications for its use on all the sites - Simple and Jetpack. It also cannot be used in Standalone plugins as is.
We're copying quite a bit of code and creating a third set of endpoints, which we should probably avoid if we can.
Yes, existing endpoints are spread all over and the logic is not consolidated, which actually resulted in the schema mess we are trying to solve. I did think about keeping the changes to minimal but it felt like creating more such mess.
The approach here tries to consolidate the endpoint which can be used everywhere - WPCOM and Jetpack sites, both in Jetpack and Social plugin.
I agree but I am confident about these changes that they will be better in the long run.
We are not touching Publicize_Base to leave that refactor for a later time. I just copied the useful bits from there which are needed for the endpoint. We can afterwards deprecate those methods in that class.
I am afraid that may lead to further complicated logic of the Publicize classes on Jetpack and WPCOM, making it harder for someone else to follow the business logic. |
cf2eaf6
to
8a796c6
Compare
if ( 'threads' === $service_name && isset( $connection['external_name'] ) ) { | ||
return 'https://www.threads.net/@' . $connection['external_name']; | ||
if ( 'threads' === $service_name && isset( $cmeta['external_name'] ) ) { | ||
return 'https://www.threads.net/@' . $cmeta['external_name']; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change is to ensure it works on WPCOM sites where connection is not an array.
@@ -527,7 +527,7 @@ public function get_profile_link( $service_name, $connection ) { | |||
} | |||
|
|||
$profile_url_query = wp_parse_url( $cmeta['connection_data']['meta']['profile_url'], PHP_URL_QUERY ); | |||
$profile_url_query_args = null; | |||
$profile_url_query_args = array(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Phan complained about this.
@@ -608,7 +608,7 @@ public function get_username( $service_name, $connection ) { | |||
* @param object|array $connection The Connection object (WordPress.com) or array (Jetpack). | |||
* @return string | |||
*/ | |||
private function get_profile_picture( $connection ) { | |||
public function get_profile_picture( $connection ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes it available externally for facade.
53a4d87
to
b0190a0
Compare
Closing in favour of #40589 as we no longer need the connections endpoint. We can remove the |
Extracted out of #40536
Proposed changes:
wpcom/v3/publicize/connections
endpoint that can be used in every scenario the publicize module is usedOther information:
Jetpack product discussion
Does this pull request change what data or activity we track or use?
Testing instructions:
wpcom/v3/sites/<site_id>/publicize/connections
?test_connections=1
to the endpoint abovestatus
is set to'broken'
for the broken connectionwp.apiFetch
e.g. Block Editor